﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using smartphone.App_Code;
using System.Data;

namespace smartphone
{
    public partial class Checkout : System.Web.UI.Page
    {
        private ShoppingCart cart = new ShoppingCart();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PopulateControl();
            }
        }

        private void PopulateControl()
        {
            GridViewCheckout.DataSource = cart.GetItems();
            GridViewCheckout.DataBind();
            GridViewCheckout.Visible = true;
            decimal amount = cart.GetTotalAmount();
            totalAmountLabel.Text = String.Format("{0:0,000}", amount) + " vnđ";
        }

        protected void placeOrderButton_Click(object sender, EventArgs e)
        {
            decimal amount = cart.GetTotalAmount();
            string orderID = cart.CreateCommerceLibOrder(1);

            //chuyen qua tramg xac nhan
            Response.Redirect("OrderPlaced.aspx");
        }
    }
}